package com.uni.exp6.service;

import com.uni.exp6.dao.ProviderMapper;
import com.uni.exp6.pojo.Provider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

@Transactional
@Service
public class ProviderServiceImpl implements ProviderService{
    @Autowired
    private ProviderMapper providerMapper;

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public int deleteProviderById(Integer id) {
        return providerMapper.deleteProviderById(id);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    //	如果当前没有事务，新建一个事务，如果已存在一个事务中，加入到这个事务，一般的选择（默认值）
    public int updateProvider(Provider provider) {
        return providerMapper.updateProvider(provider);
    }


    @Override
    public List<Provider> queryAllProvider() {
        return providerMapper.queryAllProvider();
    }

    @Override
    public List<Provider> queryProviderByName(String proName) {
        return providerMapper.queryProviderByName(proName);
    }

    @Override
    public int addProvider(Provider provider) {
        return providerMapper.addProvider(provider);
    }

}
